8 #define forsn(i, s, n) for (int i = (s); i < (n); i++)
9 #define forn(i, n) forsn (i, 0, n)
11 typedef vector
<bool> vbool
;
12 typedef vector
<vbool
> vvbool
;
19 #define node(r, c) ((r) << 12 | (c))
20 #define node_row(v) ((v) >> 12)
21 #define node_col(v) ((v) & 0xfff)
23 #define NONE 0xffffffff
25 Node
vecino(bool ns
, Node v
) {
26 #define sig(x) ((x) ? 1 : -1)
27 const int r
= node_row(v
) - ns
, c
= node_col(v
);
28 if (r
< 0 || r
>= rows
) return NONE
;
29 const int cc
= c
+ sig(ns
^ mapa
[r
][c
]);
30 if (cc
< 0 || cc
>= cols
) return NONE
;
31 const int rr
= node_row(v
) + sig(ns
) * -!(mapa
[r
][c
] ^ mapa
[r
][cc
]);
32 if (rr
< 0 || rr
> rows
) return NONE
;
37 #define marcado(v) (_marcas[node_row(v)][node_col(v)])
38 #define marcar(v) (_marcas[node_row(v)][node_col(v)] = true)
40 vvbool
_marcas(rows
+ 1, vbool(cols
, false));
44 if (marcado(v
)) continue;
50 Node vv
= vecino(direction
, v
);
51 if (vv
== NONE
|| marcado(vv
)) continue;
56 if (node_row(w
) == rows
) {
73 mapa
= vvbool(rows
, vbool(cols
));
78 mapa
[r
][c
] = (mapa_rc
== '\\');
82 cout
<< resolver() << endl
;